﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace DateBaseSyshronous
{
    public abstract class SqlModel
    {
        private string _sqlString;
        private string _tablename;
        private string _modeltype;

        public string SqlString {
            get {
                return _sqlString;
            }
            set {
                _sqlString = RegularString(value);
            }
        }

        public string TableName {
            get {
                return _tablename;
            }
            set {
                _tablename = value;
            }
        }

        public string ModelType {
            get {
                return _modeltype;
            }
            set {
                _modeltype = value;
            }
        }

        public SqlModel() {
            _sqlString = string.Empty;
            _tablename = string.Empty;
            _modeltype = string.Empty;
        }

        public SqlModel (XmlNode node) {
            XmlElement xe = (XmlElement)node;
            TableName = xe.GetAttribute("tablename").ToString();
            ModelType = xe.GetAttribute("type").ToString();
            SqlString = xe.ChildNodes[0].InnerText;
        }

        public virtual string RegularString(string value) {

            return value;
        }
    }
}
